package com.onlinelearn.paymentservice.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class OrderQueryService {
    @Autowired
    private PaymentOrderRepository orderRepository;

    public List<PaymentOrder> getStudentOrders(Long studentId, OrderQueryFilter filter) {
        return orderRepository.findByStudentIdAndFilter(studentId, filter);
    }

    public List<PaymentOrder> getTeacherCourseOrders(Long teacherId, Long courseId) {
        return orderRepository.findByCourseTeacherIdAndCourseId(teacherId, courseId);
    }

    public PaymentOrder getOrderDetails(Long orderId) {
        return orderRepository.findById(orderId)
            .orElseThrow(() -> new OrderNotFoundException(orderId));
    }
}

// 订单查询过滤器
class OrderQueryFilter {
    private PaymentOrderStatus status;
    private LocalDateTime startTime;
    private LocalDateTime endTime;
    // Getter和Setter
} 